<template>
    <div id="systemAddressBookManage" class="center_div">
        <div class="searchForm searchFormDataManageBtn22px" style="margin-top: 1%;margin-left: 1%;">
            <el-form :inline="true"  class="demo-form-inline">
                <el-form-item label="编组">
                    <el-input v-model="name"  ></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary"  @click="querySearch"class="dataManageBtn22BtnpPx">查询</el-button>
                    <el-button type="primary"  @click="add"class="dataManageBtn22BtnpPx">添加</el-button>
                    <el-button type="primary"  @click="sort"class="dataManageBtn22BtnpPx" v-if="true">调整排序</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="table-wrap" style="margin-top: -1%">
            <el-table
                    :data="tableData"
                    style="width:100%;text-align: center;"
                    border
                    cell-class-name="dataManage18px"
                    :header-cell-style="headerCellClassName">
                <el-table-column align="center" v-for="title in tableTitle" :prop="title.prop" :label="title.label"  :show-overflow-tooltip="title.overflowTooltip">
                </el-table-column>
                <template v-if="buttons && buttons.length!==0">
                    <el-table-column
                            class="align-right"
                            width="320"
                            header-align="center"
                            label="操作"
                            align="center" >
                        <template slot-scope="scope">
                            <el-button v-for="button in buttons"
                                       @click="operate(scope.row,button.href)" :type="button.type"
                                       class="el-button el-button--text  dataManageBtn22px">{{button.label}}
                            </el-button>
                        </template>
                    </el-table-column>
                </template>
            </el-table>
            <el-pagination
                    layout="total,prev, pager, next"
                    background
                    @current-change="changePageNum"
                    :current-page="pageNum"
                    :page-size="pageSize"
                    :total="total">
            </el-pagination>
        </div>
        <!--调整排序组件-->
        <el-dialog :title="title" :visible.sync="showSort" width="60%"  append-to-body @close="updateIndex">
            <div ref="myChat"></div>
            <el-table
                    :data="groupData"
                    style="width:100%;text-align: center;"
                    border
                    class="sortTableClass"
                    cell-class-name="dataManage18px"
                    :header-cell-style="headerCellClassName">
                <el-table-column align="center" v-for="title in sortTableTitle" :prop="title.prop" :label="title.label"  :show-overflow-tooltip="title.overflowTooltip">
                </el-table-column>
                <template>
                    <el-table-column
                            class="align-right"
                            width="230px"
                            align="center"
                            label="操作">
                        <template slot-scope="scope">
                            <span><img src="@/assets/images/mapicon/sortOperate.png"
                                       class="sortmapiconOne"></span>
                            <span><img src="@/assets/images/mapicon/sortUp.png"
                                       class="sortmapicoTwo"
                                       @click="sortUp(scope.row)"></span>
                        </template>
                    </el-table-column>
                </template>
            </el-table>
            <el-pagination
                    v-if="false"
                    class="dataManage18px"
                    layout="total,prev, pager, next"
                    background
                    @current-change="changeSortPageNum"
                    :current-page="sortPage.pageNum"
                    :page-size="sortPage.pageSize"
                    :total="sortlimitData.length">
            </el-pagination>

        </el-dialog>
        <div>
            <el-dialog :title="title" :visible.sync="showBox" width="40%" append-to-body @close="closeDialog">
                <el-form ref="form" :model="form" :rules="rules" label-width="140px" >
                    <el-row>
                        <el-col >
                            <el-form-item label="归属部门" prop="fleetName">
                                <el-select v-model="form.fleetName" :placeholder="'请选择'" filterable>
                                    <el-option :value="form.fleetName" style="height: auto">
                                        <el-tree
                                                :load="loadChildren"
                                                highlight-current
                                                lazy
                                                node-key="id"
                                                :props="defaultProps"
                                                :filter-node-method="filterNode"
                                                ref="tree"
                                                @node-click="loadData">
                                            <span class="custom-tree-node dataManage18px"
                                                  slot-scope="{ node, data }">
                                            <span v-if="data.type===0"><img src="@/assets/images/mapicon/tree_fleet.png"
                                                                            class="treeLableImg">{{ node.label }}</span>
                                            <span v-if="data.type===1"><img src="@/assets/images/mapicon/tree_fleet.png"
                                                                            class="treeLableImg" >{{ node.label }}</span>
                                        </span>

                                        </el-tree>
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col >
                            <el-form-item label="编组" prop="name">
                                <el-input v-model="form.name"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-form-item label="描述">
                            <el-input v-model="form.remark" type="textarea"></el-input>
                        </el-form-item>
                    </el-row>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button  @click="closeBox" class="dataManageBtn22BtnpPx">取 消</el-button>
                    <el-button type="primary" @click="addSystemAddressBook('form')" v-show="showAdd"class="dataManageBtn22BtnpPx">添 加
                    </el-button>
                    <el-button type="primary" @click="updateSystemAddressBook('form')" v-show="!showAdd"class="dataManageBtn22BtnpPx">修 改
                    </el-button> </div>
            </el-dialog>
        </div>
        <div>
            <el-dialog v-if="loadTree" :title="title" width="70%" :visible.sync="showManageBox" @close="manageDialogClose"
                       append-to-body>
                <div>
                    <div  class="groupMgStyleBigBoxLeft">
                        <div style="height:99%;width:99%;margin-top:1%;background:white;overflow:auto">
                            <el-tree check-strictly
                                     :load="loadFleetAndSub"
                                     show-checkbox
                                     highlight-current
                                     lazy
                                     node-key="id"
                                     :props="defaultPropss"
                                     :filter-node-method="filterNode"
                                     ref="manageTree"
                                     @check-change="handleCheckChange">
                                  <span class="custom-tree-node dataManage18px"  slot-scope="{ node, data }">
                                <span v-if="data.type===0"><img src="@/assets/images/mapicon/tree_fleet.png"
                                                                class="treeLableImg">{{ node.label }}</span>
                                <span v-if="data.type===1"><img src="@/assets/images/mapicon/tree_fleet.png"
                                                                class="treeLableImg">{{ node.label }}</span>
                                <span v-if="data.type===2"><img src="@/assets/images/mapicon/tree_sub.png"
                                                                class="treeLableImg">{{ node.label }}</span>
                                      <span v-if="data.type===3"><img src="@/assets/images/mapicon/zuoxiUser.png"
                                                                      class="treeLableImg">{{ node.label }}</span>
                            </span>
                            </el-tree>
                        </div>
                    </div>
                    <div class="groupMgStyleBigBox">
                    <el-table
                            :data="memberTableData"
                            style="width:100%;text-align: center;"
                            border
                            class="groupMgTableClass"
                            cell-class-name="memberMgdataManageText"
                            :header-cell-style="headerCellClassName">
                        <el-table-column align="center" v-for="title in memberTableDataTableTitle" :prop="title.prop" :label="title.label"  :show-overflow-tooltip="title.overflowTooltip">
                        </el-table-column>
                        <template>
                            <el-table-column
                                    class="align-right"
                                    width="230px"
                                    align="center"
                                    label="操作">
                                <template slot-scope="scope">
                            <!--<span><img src="@/assets/images/newIcon/sortUp.png"
                                       class="groupMgStyle"
                                       @click="sortUpUp(index)">
                            </span>-->
                                    <span>
                                        <el-button @click="deleteMember(scope.row.subId)" type="text"
                                                   class="el-button el-button--text  memberMgdataManageBtn">删除</el-button></span>
                                </template>
                            </el-table-column>
                        </template>
                    </el-table>
                        <el-pagination
                                v-if="false"
                                class="dataManage18px"
                                layout="total,prev, pager, next"
                                background
                                @current-change="changesAddPageNum"
                                :current-page="addPage.pageNum"
                                :page-size="addPage.pageSize"
                                :total="memberTableData.length">
                        </el-pagination>
                    </div>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="showManageBox = false" class="dataManageBtn22BtnpPx">取 消</el-button>
                    <el-button type="primary" @click="addSystemAddressBookMember" class="dataManageBtn22BtnpPx">确 定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>

</template>

<script>
  import SystemAddressBookManage from '@/api/dataManages/SystemAddressBookManage';
  import Sortable from 'sortablejs';

  export default {
    name: 'SystemAddressBookManage',
    props: {
      FleetId: Number,
      userId: Number,
    },
    data() {
      return {
        name: '',
        loadTree: true,
        tableTitle: [
          {label: '编组', prop: 'name',overflowTooltip:true},
          {label: '部门', prop: 'fleetName',overflowTooltip:true},
          {label: '描述', prop: 'remark',overflowTooltip:true},
        ],
        sortTableTitle: [
          {label: '编组', prop: 'name',overflowTooltip:true},
          {label: '所属部门', prop: 'fleetName',overflowTooltip:true},
          {label: '描述', prop: 'remark',overflowTooltip:true},
        ],memberTableDataTableTitle: [
          {label: '终端名称', prop: 'subName',overflowTooltip:true},
          {label: '分机号', prop: 'extnum',overflowTooltip:true},
        ],
        tableData: [],
        memberTableTitle: [
          {label: '成员', prop: 'subName'},
          {label: '归属部门', prop: 'fleetName'},
          {label: '编组', prop: 'groupName'},
        ],
        memberTableData: [],
        groupName: [],
        total: 0,
        pageNum: 1,
        pageSize: 8,
        sortPage:{
          total: 0,
          pageNum: 1,
          pageSize: 8,
        },
        addPage:{
          total: 0,
          pageNum: 1,
          pageSize: 4,
        },
        buttons: [{label: '编辑', href: 'update'}, {label: '删除', href: 'delete'}, {label: '成员管理', href: 'manage'}],
        showBox: false,
        showManageBox: false,
        showAdd: true,
        title: '',
        form: {
          id: '',
          name: '',
          fleetName: '',
          fleetId: '',
          remark: '',
        },
        formName: '',
        rules: {
          name: [
            {required: true, message: '请输入编组名称', trigger: 'blur'},
            {min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur'}
          ],
          fleetName: [
            {required: true, message: '请选择归属部门', trigger: 'change'},
          ],
        },
        defaultProps: {
          label: 'name',
          isLeaf: 'isLeaf',
        },
        defaultPropss: {
          label: 'name',
          isLeaf: 'isLeaf',
        },
        groupId: '',
        groupData: [],
        showSort: false,
        drawBodyWrapper:'',
        drawheaderWrapper:'',
      };
    },
    created() {
      this.changeDmgPage();
    },
    mounted() {
      this.query();
    },
    computed:{
      remarkA(){
        return this.form.remark;
      },
      sortlimitData() {
        // let data = [...this.groupData];
        return this.groupData;
      },
      dataWithSortPage() {
        const data = this.sortlimitData;
        const start = this.sortPage.pageNum * this.sortPage.pageSize - this.sortPage.pageSize;
        const end = start + this.sortPage.pageSize;
        return [...data].slice(start, end);
      },
      addlimitData() {
        // let data = [...this.groupData];
        return this.memberTableData;
      },
      dataWithAddPage() {
        const data = this.addlimitData;
        const start = this.addPage.pageNum * this.addPage.pageSize - this.addPage.pageSize;
        const end = start + this.addPage.pageSize;
        return [...data].slice(start, end);
      },
    },
    watch:{
      remarkA(val){
        if(val.length>100){
          this.$message.error("描述不能超过100位字符")
          this.form.remark.substring(0,100);
        }
      }
    },
    methods: {
      querySearch(){
        this.query(1);
        this.pageNum = 1;
      },
      changeDmgPage(){
        let w = window.screen.width;
        let h = window.screen.height;
        if (w == 1920) {
          if (h == 1080) {
          } else {
            this.pageSize = 11
          }
        }
      },
      //表头样式
      headerCellClassName() {
        return 'font-size:18px;color:#515A6E;padding:10px 0px 10px 0px !important;background:#F5F5F6;border:1px solid #EBEBEB';
      },
      //表格样式
      cellStyleClassName() {
        return 'font-size:13px;text-align:center;color:#606266;padding:5px 0px 5px 0px !important;border:1px solid #EBEBEB';
      },

      manageDialogClose() {
        this.showManageBox = false;
        this.loadTree = false;
        setTimeout(() => {
          this.loadTree = true;
        }, 100);
      },
      updateIndex: function() {
        console.log(this.groupData);
        var that = this;
        var auditData = {
          dcId: this.$store.getters.userAccount,
          type: 5,
          status: '成功',
          describe: this.$store.getters.userName + "更新系统通讯录"+that.groupData.name,
          time: new Date,
          fleetId: this.$store.getters.scsFleetId,
          detailType: 28,
          remark: '',
        };
        SystemAddressBookManage.updateSystemAddressBookIndex({groupData: that.groupData}).then(res => {
          var res = res;
          if (res.success) {
            that.query(1);
            this.GlobalFunc.GlaAddAudit(auditData);

          } else {
            that.$message(res.msg);
            auditData.status = "失败";
            this.GlobalFunc.GlaAddAudit(auditData);

          }
        }).catch(err => {
          // 异常情况
          console.log(err);
          auditData.status = "异常";
          this.GlobalFunc.GlaAddAudit(auditData);
        });
      },
      sortUp: function(row) {
        console.log("索引："+row.index);
        for (var i = 0; i<this.groupData.length; i++) {
          if(this.groupData[i].id == row.id){
            this.groupData.splice(i,1);
          }
        }
        this.groupData.unshift(row);
      },
      sortUpUp: function(index) {
        let temp = this.memberTableData[index];
        for (var i = index; i > 0; i--) {
          this.$set(this.memberTableData, i, this.memberTableData[i - 1]);
        }
        this.$set(this.memberTableData, 0, temp);
      },
      sort: function() {
        var data = {
          fleetId: this.FleetId,
          pageNum: 1,
          pageSize: 100000,
        };
        this.groupData = [];
        SystemAddressBookManage.getSystemAddressBook(data).then(res => {
          if (res.success) {
            this.groupData = res.obj.list;
          } else {
            this.$message.error('查询失败');
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
        });
        this.title = '调整排序',
            this.showSort = true;
        this.$nextTick(()=>{
          let id = this.$refs.myChat;
          let tableColumn = this.$refs.tableColumn;
          const drawBodyWrapper = document.querySelector('.el-dialog__body tbody')
          const drawheaderWrapper = document.querySelector('.el-table__header-wrapper tr')
          this.drawBodyWrapper = drawBodyWrapper;
          this.drawheaderWrapper = drawheaderWrapper;
          this.rowDrop1()
        })
      },
      rowDrop1(){
        setTimeout(()=> {
          var el = this.drawBodyWrapper;
          this.sortable = Sortable.create(el, {
            onEnd: (evt)=> {
              let itemEl = evt.item;
              let oldIndex = evt.oldIndex;
              let newIndex = evt.newIndex;
              let temp = this.groupData[oldIndex];
              if (oldIndex < newIndex) {
                for (let i = oldIndex; i < newIndex; i++) {
                  this.groupData[i] = this.groupData[i + 1];
                }
              } else if (oldIndex > newIndex) {
                for (let i = oldIndex; i > newIndex; i--) {
                  this.groupData[i] = this.groupData[i - 1];
                }
              }
              this.groupData[newIndex] = temp;
            },
          });
        }, 100);
      },
      //行拖拽
      rowDrop() {
        const tbody =   this.drawBodyWrapper
        const _this = this
        Sortable.create(tbody, {
          onEnd({ newIndex, oldIndex }) {
            const currRow = _this.groupData.splice(oldIndex, 1)[0]
            _this.groupData.splice(newIndex, 0, currRow)
          }
        })
      },
      loadChildren: function(node, resolve) {
        if (node.data) {
          this.getChild(node.data.id, node.data.type, resolve);
        } else {
          setTimeout(() => { this.getChild(this.FleetId, 0, resolve);}, 0);
        }
      },
      getChild: function(id, type, resolve) {
        var jsonData = {
          parentId: id,
          type: type,
        };
        SystemAddressBookManage.getFleet(jsonData).then(res => {
          if (res.success) {
            var childNodes = [];
            if (res.obj) {
              childNodes = res.obj;
            }
            resolve(childNodes);
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
        });
      },
      filterNode: function(value, data) {
        if (!value)
          return true;
        else
          return data.name.indexOf(value) !== -1;
      },
      loadData: function(node) {
        this.form.fleetName = node.name;
        this.form.fleetId = node.id;
        // $('.el-select-dropdown').hide()


      },
      loadFleetAndSub(node, resolve) {
        if (node.data) {
          if (node.data.type === 2) {
            var childNodes = [];
            return resolve(childNodes);
          } else {
            this.getFleetAndSub(node.data.id, node.data.type, resolve);
          }
        } else {
          setTimeout(() => { this.getFleetAndSub(this.FleetId, 0, resolve);}, 0);
        }
      },
      getFleetAndSub: function(id, type, resolve) {
        var jsonData = {
          parentId: id,
          type: type,
        };
        SystemAddressBookManage.getFleetAndSub(jsonData).then(res => {
          if (res.success) {
            var childNodes = [];
            if (res.obj && res.obj.length > 0) {
              for (var i = 0; i < res.obj.length; i++) {
                if (res.obj[i].type === 2||res.obj[i].type === 3) {
                  res.obj[i].isLeaf = true;
                }else {
                  res.obj[i].disabled = true;
                }
              }
              childNodes = res.obj;
            } else {
              var node = this.$refs.manageTree.getNode(id);
              node.loading = false;

              return;
            }
            resolve(childNodes);
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
        });
        setTimeout(() => {
          for (var i = 0; i < this.memberTableData.length; i++) {
            var node = this.$refs.manageTree.getNode(this.memberTableData[i].subId);
            if (node != null && node.checked === false) {
              node.checked = true;
            }
          }
        }, 200);
      },
      deleteMember: function(id) {
        for (var i = 0; i < this.memberTableData.length; i++) {
          if (id === this.memberTableData[i].subId) {
            this.memberTableData.splice(i, 1);
            var node = this.$refs.manageTree.getNode(id);
            node.checked = false;
          }
        }
      },
      handleCheckChange: function(data, checked, indeterminate) {
        console.log("选择数据");
        console.log(data);
        console.log(checked);
        if (checked) {
          var nodeObj = {};
          nodeObj.subId = data.id;
          nodeObj.extnum = data.extNumber;
          nodeObj.subName = data.name;
          nodeObj.type = data.type;
          if(data.type ==2){
            nodeObj.type = 0
          }else if(data.type ==3){
            nodeObj.type =3
          }
          var length = false;
          for (var i = 0; i < this.memberTableData.length; i++) {
            if (data.id === this.memberTableData[i].subId) {
              length = true;
            }
          }
          if (!length) {
            this.memberTableData.push(nodeObj);
          }
        } else if (!checked) {
          console.log(this.memberTableData);
          for (var i = 0; i < this.memberTableData.length; i++) {
            if (data.id === this.memberTableData[i].subId) {
              this.memberTableData.splice(i, 1);
            }
          }
        }
      },
      refreshNodeBy() {
        var node = this.$refs.tree.getNode(this.FleetId);
        node.loaded = false;
        node.expand();
      },
      formClear: function() {
        this.form.id = '';
        this.form.name = '';
        this.form.fleetId = '';
        this.form.fleetName = '';
        this.form.remark = '';
      },
      query: function(pageNum) {
        var data = {
          fleetId: this.FleetId,
          name: this.name || '',
          pageNum: pageNum || this.pageNum,
          pageSize: this.pageSize,
        };
        SystemAddressBookManage.getSystemAddressBook(data).then(res => {
          var data = res;
          if (res.success) {
            this.tableData = data.obj.list;
            this.total = data.obj.total;
            this.name = '';
            // 子组件调用父组件方法，并传递参数
            this.$emit('ChildgetChangeSystemAddressBookDatas');
          } else {
            this.$message('');
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
        });
      },
      getMemberTableData: function(id) {
        SystemAddressBookManage.getMemberTableData({groupId: id}).then(res => {
          var data = res;
          if (res.success) {
               console.info("%c getMemberTableData","color:red");
            this.memberTableData = data.obj.list;
          } else {
            this.$message('');
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
        });
      },
      add: function() {
        var that = this;
        that.formClear();
        that.showBox = true;
        that.showAdd = true;
        that.title = '添加';
      },
      closeDialog() {
        this.$nextTick(() => {
          this.$refs['form'].resetFields();
        });
      },
      addSystemAddressBook(formName) {
        let validate = false;
        this.$refs[formName].validate((valid) => {
          if (valid) {
            validate = true;
          } else {
            validate = false;
            return false;
          }
        });
        if (validate === false) {
          return;
        }
        var data = {
          name: this.form.name,
          fleetId: this.form.fleetId,
          remark: this.form.remark,
        };
        /*     if(this.form.name===''){
               this.$message('编组不能为空');
               return
             }
             if(this.form.fleetId===''){
               this.$message('归属部门不能为空');
               return
             }*/
        var auditData = {
          dcId: this.$store.getters.userAccount,
          type: 5,
          status: '成功',
          describe: this.$store.getters.userName + "添加系统通讯录:"+data.name,
          time: new Date,
          fleetId: this.$store.getters.scsFleetId,
          detailType: 28,
          remark: '',
        };
        SystemAddressBookManage.addSystemAddressBook(data).then(res => {
          if (res.success) {
            if (res.obj.count === 1) {
              this.closeBox();
              this.$message.success('添加成功');
              this.GlobalFunc.GlaAddAudit(auditData);

              this.query();

            } else {
              auditData.status = "编组已存在";
              this.GlobalFunc.GlaAddAudit(auditData);
              this.$message('编组已存在');

            }
          } else {
            auditData.status = "失败";
            this.GlobalFunc.GlaAddAudit(auditData);
            this.$message('添加失败');
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
          auditData.status = "异常";
          this.GlobalFunc.GlaAddAudit(auditData);
        });
      },
      updateSystemAddressBook(formName) {
        let validate = false;
        this.$refs[formName].validate((valid) => {
          if (valid) {
            validate = true;
          } else {
            validate = false;
            return false;
          }
        });
        if (validate === false) {
          return;
        }
        var data = {
          id: this.form.id,
          name: this.form.name,
          fleetId: this.form.fleetId,
          remark: this.form.remark,
        };
        data.userId = this.userId;

        var auditData = {
          dcId: this.$store.getters.userAccount,
          type: 5,
          status: '成功',
          describe: this.$store.getters.userName + "修改系统通讯录:"+data.name,
          time: new Date,
          fleetId: this.$store.getters.scsFleetId,
          detailType: 28,
          remark: '',
        };
        SystemAddressBookManage.updateSystemAddressBook(data).then(res => {
          if (res.success) {
            if (res.obj.count === 1) {
              this.closeBox();
              this.$message.success('编辑成功');
              this.GlobalFunc.GlaAddAudit(auditData);

              this.query();
            } else {
              this.$message('编组已存在');
              auditData.status = "编组已存在";
              this.GlobalFunc.GlaAddAudit(auditData);
            }
          } else {
            this.$message('编辑失败');
            auditData.status = "失败";
            this.GlobalFunc.GlaAddAudit(auditData);
          }
        }).catch(err => {
          // 异常情况
          auditData.status = "异常";
          this.GlobalFunc.GlaAddAudit(auditData);
          console.log(err);
        });
      },
      closeBox: function() {
        this.formClear();
        this.showBox = false;
        this.showManageBox = false;
      },
      operate: function(row, href) {
        var that = this;
        that.formClear();
        if (href.indexOf('update') !== -1) {
          that.showBox = true;
          that.showAdd = false;
          that.title = '编辑';
          that.form.id = row.id;
          that.form.name = row.name;
          that.form.fleetName = row.fleetName;
          that.form.fleetId = row.fleetId;
          that.form.remark = row.remark;

        } else if (href.indexOf('delete') !== -1) {
          var auditData = {
            dcId: this.$store.getters.userAccount,
            type: 5,
            status: '成功',
            describe: this.$store.getters.userName + "删除系统通讯录:"+row.name,
            time: new Date,
            fleetId: this.$store.getters.scsFleetId,
            detailType: 28,
            remark: '',
          };
          this.$confirm('是否确定删除', '', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(() => {
            SystemAddressBookManage.deleteSystemAddressBook({id: row.id}).then(res => {
              if (res.success) {
                 this.GlobalFunc.GlaAddAudit(auditData);
                that.$message.success('删除成功');
                that.query();
              }else {
                auditData.status = "失败";
                this.GlobalFunc.GlaAddAudit(auditData);
              }
            }).catch(err => {
              // 异常情况
              console.log(err);
              auditData.status = "异常";
              this.GlobalFunc.GlaAddAudit(auditData);
            });
          }).catch(() => {
          });

        } else {
            that.groupName = row.name;
          that.showManageBox = true;
          that.title = '成员管理';
          that.groupId = row.id;
          that.getMemberTableData(row.id);
        }
      },
      deleteSystemAddressBookMember: function(row) {
        var that = this;
        this.$confirm('是否确定删除', '', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
        }).then(() => {
          SystemAddressBookManage.deleteSystemAddressBookMember({subId: row.subId, groupId: row.groupId}).then(res => {
            if (res.success) {
              that.$message.success('删除成功');
              that.getMemberTableData(row.groupId);
              that.refreshNodeBy(this.FleetId);
            }
          }).catch(err => {
            // 异常情况
            console.log(err);
          });
        }).catch(() => {
        });

      },
      addSystemAddressBookMember() {
       /* if (this.memberTableData.length <= 0) {
          console.log('添加');
          this.$message.warning('请先选择成员');
          return false;
        }*/
        var auditData = {
          dcId: this.$store.getters.userAccount,
          type: 5,
          status: '成功',
          describe: this.$store.getters.userName + "添加该系统通讯录成员:"+this.groupName,
          time: new Date,
          fleetId: this.$store.getters.scsFleetId,
          detailType: 28,
          remark: '',
        };
        SystemAddressBookManage.addSystemAddressBookMember(
            {groupId: this.groupId, memberTableData: this.memberTableData}).then(res => {
          if (res.success) {
            if (res.obj.count === 1) {
              this.$message.success('添加成功');
              this.showManageBox = false;
               this.GlobalFunc.GlaAddAudit(auditData);
            } else {
              this.$message('添加失败');
              auditData.status = "失败";
              this.GlobalFunc.GlaAddAudit(auditData);
            }
          } else {
            this.$message('添加失败');
            auditData.status = "失败";
            this.GlobalFunc.GlaAddAudit(auditData);
          }
        }).catch(err => {
          // 异常情况
          console.log(err);
          auditData.status = "异常";
          this.GlobalFunc.GlaAddAudit(auditData);
        });
      },
      changePageNum: function(val) {
        this.pageNum = val;
        this.query();
      },changeSortPageNum(val) {
        this.sortPage.pageNum = val;
      },
      changesAddPageNum: function(val) {
        this.addPage.pageNum = val;
      },
    },
  };
</script>

<style scoped>
    .el-dialog__body {
        /*height: 30vh;*/
        overflow: auto;
    }
   /deep/ .el-icon-caret-right:before {
        font-size: 40px!important;
    }
    /deep/ .el-checkbox {
        height: 30px;
        width: 30px;
    }

    /deep/ .el-checkbox__inner {
        width: 30px;
        height: 30px;
    }

    /deep/ .el-checkbox /deep/ .el-checkbox__inner {
        height: 30px;
        width: 30px;
    }

    /deep/ .el-checkbox /deep/ .el-checkbox__input {
        vertical-align: middle!important;
    }

    /deep/ .el-checkbox /deep/ .el-checkbox__inner:before {
        font-size: 20px;
        margin: 3px auto auto 3px;
        text-align: center;
        line-height: 40px;
    }

    /deep/ .el-checkbox /deep/ .el-checkbox__inner:after {
        height: 12px;
        width: 12px;
        font-size: 20px;
        margin: 3px auto auto 3px;
        text-align: center;
        /*line-height: 40px;*/
    }
    /deep/ .el-tree-node__content {
        height: 40px !important;
    }

    /deep/ .el-form-item__label{
        font-size: 22px!important;
    }
    /deep/ .el-input__inner{
        font-size: 22px!important;
    }
    /deep/ .el-tree-node {
        margin-top: 25px !important;
        height: auto;
    }

    /deep/ .el-dialog__title {
        font-size: 22px;
    }
    /deep/ .el-textarea__inner {
        font-size: 20px;
    }
    /deep/ .el-icon-close:before {
        font-size: 25px;
    }

    /*分页修改开始*/
    .el-pagination /deep/ .el-pagination__total {
        font-size: 20px;
        line-height: 60px;
    }.el-pagination /deep/ button /deep/ .el-icon .el-icon .el-icon-arrow-left {
         font-size: 50px;
         height: 60px;
         width: 40px;
     }
    /deep/ .el-pager li{
         margin-top: 15px;
         height: 60px;
         width: 60px;
         line-height: 60px;
         font-size: 18px;
     }
    /deep/  .el-pagination.is-background .btn-prev, .el-pager li{
        height: 60px;
        width: 60px;
    }/deep/ .el-pagination.is-background .btn-next, .el-pager li{
         height: 60px;
         width: 60px;
     }/deep/ .el-pagination .btn-prev  .el-icon{
          font-size: 40px;
      }/deep/ .el-pagination .btn-next .el-icon{
           font-size: 40px;
       }
    /*分页修改结束*/
    #systemAddressBookManage.el-checkbox__input > .el-checkbox__inner {
        display: none;
    }

    #systemAddressBookManage.is-leaf + .el-checkbox .el-checkbox__inner {
        display: inline-block;
    }

    @media (max-width: 1366px) {
        #systemAddressBookManage .table-wrap {
            height: 800px !important;
            overflow: auto;
        }
    }

    .treeBox {
        float: left;
        width: 40%;
        height: 500px;
        overflow: auto;
    }

    .table-head {
        background-color: #EEF4FF;
        color: #333333;
        font-weight: normal;
        font-size: 18px;
        font-family: SourceHanSansCN;
        border: none;
        padding: 12px 15px;
        text-align: left !important;
    }

    .table-croll {
        display: table;
        padding: 0px;
        width: 100%;
    }

    .croll {
        display: table-row;
        list-style: none;
        height: 30px;
        width: 100%;
        border-top: 0px;
        font-size: 16px;
        color: #333333;
        cursor: move;
        margin-block-start: 0em;
        margin-block-end: 0em;
        margin-inline-start: 0px;
        margin-inline-end: 0px;
        padding-inline-start: 0px;
        line-height: 25px;
        text-align: left ! important;
    }

    .croll li {
        display: table-cell;
        float: left;
        width: 25%;
        text-indent: 2em;
        list-style-type: none;
        height: 25px;
        padding-left: 5px;
        overflow: hidden;
        white-space: nowrap;
        vertical-align: middle;
        text-overflow: ellipsis
    }

    .croll:nth-of-type(even) {
        background: #f0f3f6;
    }

    .searchForm {
        /*margin: 1% 0% 0 20%;*/
    }

    .searchFormBtn {
        margin-left: 5px;
        display: inline-block;
    }

    .tableOverF {
        height: 300px;
        overflow: auto;
    }

    .groupMgStyleBigBoxLeft{
        float:left;
        width:40%;
        height:450px
    }
    .groupMgStyleBigBox {
        float: right;
        width: 60%;
        height: 450px;
        background: ghostwhite;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .groupMgStyle {
        height: 23px;
        width: 23px;
        margin-right: 8px;
        vertical-align: middle;
        cursor: pointer
    }
    .treeLableImg {
        height: 25px;
        width: 25px;
        margin-right: 10px;
        vertical-align: middle
    }

    .treeLableImg25 {
        height: 25px;
        width: 25px;
        margin-right: 10px;
        vertical-align: middle;
        cursor: pointer
    }

    .sortTableClass{
        height: 600px;
        overflow-y: auto;
    }


    .sortmapiconOne{
        height: 30px;
        width: 30px;

    } .sortmapicoTwo{
              height: 40px;
              width: 40px;
        margin-left: 20px;
        vertical-align: center;
    }
</style>
